import request from '@/utils/request'
/**
 * 获取文章新闻推荐
 * @param {string|number} channel_id 频道ID
 * @param {number} timestamp 时间戳，请求新的推荐数据传当前的时间戳，请求历史推荐传指定的时间戳
 * @returns Promise
 */
export const getArticlesAPI = (channel_id, timestamp) => {
  return request({
    url: '/v1_0/articles',
    params: {
      channel_id,
      timestamp
    }
  })
}
/**
 * 获取新闻详情
 * @param {string} article_id 文章id
 * @returns Promise
 */
export const getArticlesDetailsAPI = (article_id) => {
  return request({
    url: `/v1_0/articles/${article_id}`
  })
}
/**
 * 取消收藏文章
 * @param {string} target 文章id
 * @returns Promise
 */
export const delArticlesCollectionAPI = (target) => {
  return request({
    url: `/v1_0/article/collections/${target}`,
    method: 'DELETE'
  })
}
/**
 * 收藏文章
 * @param {string} target 文章id
 * @returns Promise
 */
export const postArticlesCollectionAPI = (target) => {
  return request({
    url: '/v1_0/article/collections',
    data: {
      target
    }
  })
}
